home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000128_icon-group-sender_Mon Oct 30 13:12:42 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9UKCYJ06208
for icon-group-addresses; Mon, 30 Oct 2000 13:12:34 -0700 (MST)
Message-Id: <200010302012.e9UKCYJ06208@baskerville.CS.Arizona.EDU>
From: symbiot@my-deja.com
X-Newsgroups: comp.lang.icon
Subject: How would the experts handle this...??
Date: Mon, 30 Oct 2000 19:13:49 GMT
X-Article-Creation-Date: Mon Oct 30 19:13:49 2000 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt)
X-Http-Proxy: 1.0 SRVPROXY, 1.0 x67.deja.com:80 (Squid/1.1.22) for client 208.51.185.226
X-MyDeja-Info: XMYDJUIDsymbiot
To: icon-group@cs.arizona.edu
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2223
Greetings! And welcome to my latest edition of "Questions from the
Newbie"
The situation is this:
I wish to scan thru a file and determine how letters "connect" with one
another. By that I mean that for every letter of the alphabet, I would
like to compile two lists: one containing all the letters which apper
to the right of the given letter, and another for all those appearing
to the left.
Exmaple:
For the line....
"Cable television programming is...."
The output would might look something like:
A: left- Cr
right- bm
B: left- a
right- l
.
.
.
I: left- vsm(blank)
right- sns
etc etc etc
Here's how I have tackled the problem:
while line := read(data) do
{
index := 0
while index <= *line do
{
if not(line[index+1] == " ") then
{
centerchar := line[index+1]
leftchar[centerchar] := leftchar[centerchar] || line[index]
rightchar[centerchar] := rightchar[centerchar] || line[index +2]
} #if not....
index +:= 1
# do it again
}# end (while index <= *line)
}# end (while line := read(data))
#generate output
write(output,"LETTERS ORGANIZED BY CENTER CHARACTER FOR FILE ",filename)
index := 0
while index <= 52 do
{
if ((*leftchar[&letters[index]] > 1) | (*rightchar[&letters[index]]
> 1)) then
{
write(output,leftchar[&letters[index]])
write(output,&letters[index])
write(output,rightchar[&letters[index]])
} # end if
write(output," ") #add blank line to output for clarity
index +:= 1
} # end while index
-----
Thus far, I have been roundly criticized by icon afficiandos for my use
of explicit indexing. It seems to me an intuitive way to handle the
problems I've faced and makes the program "readable" to the layman.
But, be that as it may, I'm curious as to how those "in the know" would
handle this problem in a more "icon-esque" fashion.
Your suggestions are greatly appreciated.
Thanx!!
--
"Credibility depends on two semiconflicting rules. First, the system
must be complicated enough to seem scientific. And second, the results
must match, more or less, people's nonscientific prejudices."
Nicholas Thompson
Washington Monthly
14 Sep 00
Sent via Deja.com http://www.deja.com/
Before you buy.